<?php
// 桥接模式
// 将一个类的一部分行为和属性，交给其他类去完成
// 理解为 一个类的行为和属性 是由其他类组成的
// 
// abstraction: 抽象接口，需要桥接的部分的方法 api
// implements: 具体的方法 shape
interface DrawingAPI
{
	public function draw();
}

class DrawingAPI1 implements DrawingAPI
{
	public function draw()
	{

	}
}

class DrawingAPI2 implements DrawingAPI
{
	public function draw()
	{

	}
}

interface Shape
{
	public function draw();
	public function resize();
}

class CircleShape implements Shape
{
	private $x;
	private $y;
	private $z;
	private $drawingAPI;

	public function __construct($x, $y, $z, DrawingAPI $drawingAPI)
	{
		$this->x = $x;
		$this->y = $y;
		$this->z = $z;
		$this->drawingAPI = $drawingAPI;
	}

	public function draw()
	{
		return $this->drawingAPI->draw();
	}

	public function resize()
	{
	}
}

$drawingAPI1 = new DrawingAPI1;
$drawingAPI2 = new DrawingAPI2;
$circleShape = new CircleShape(0, 0, 0, $drawingAPI1);